package com.yykj.hospital.server.converter;

import com.yykj.hospital.client.dto.HospitalAdminRoleDTO;
import com.yykj.hospital.server.model.entity.HospitalAdminRole;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;

public class HospitalAdminRoleDTOConverter {
    public static HospitalAdminRoleDTO convert(HospitalAdminRole item){
        HospitalAdminRoleDTO dto = new HospitalAdminRoleDTO();
        BeanUtils.copyProperties(item,dto);
        if(StringUtils.isEmpty(item.getOauthIds())){
            dto.setOauthIds(new ArrayList<>());
        }else{
            dto.setOauthIds(Arrays.asList(item.getOauthIds().split(",")));
        }
        return dto;
    }
}
